package com.liming.service;

import com.liming.dao.Userdao;
import com.liming.model.User;
import com.liming.utils.Md5Utils;

public class UserService {
	Userdao userdao=new Userdao();
	public User login(String username,String password){
		String pwd=Md5Utils.md5(password);
		return userdao.findUser(username, pwd);
	}
	
	public boolean regist(User user){
		if(userdao.findUser(user.getUsername())){
			System.out.println("true");	
		}else{
			System.out.println("false");
			user.setPassword(Md5Utils.md5(user.getPassword()));
			if(userdao.addUser(user)!=0){
				return true;	
			}
		}
		return false;
	}
	public boolean isEnable(String username){
		if(userdao.findUser(username)){
			return false;
		}else{
			return true;
		}
		
	}
}
